function stop = h2out(tt, uu, flag, params)
  stop = 0;
  
  if (~params.plotHydro)
    return
  end

  global h2out_lasttime h2out_points h2out_lastu h2out_nlines;
  if strcmp(flag, 'init')
    h2out_lastu = zeros(2, params.Nx, params.Ny);
    h2out_lasttime = 0;
    h2out_nlines = 12;
    h2out_points = zeros(h2out_nlines*(params.Nx+params.Ny), 2);

    for l=1:h2out_nlines
      h2out_points(h2out_nlines*params.Nx + (l-1)*params.Ny+1 : h2out_nlines*params.Nx + l*params.Ny, 1) = (l-1)*params.Lx/h2out_nlines;
      h2out_points(h2out_nlines*params.Nx + (l-1)*params.Ny+1 : h2out_nlines*params.Nx + l*params.Ny, 2) = (0:params.Ny-1)/params.Ny*params.Ly;

      h2out_points((l-1)*params.Nx+1 : l*params.Nx, 1) = (0:params.Nx-1)/params.Nx*params.Lx;
      h2out_points((l-1)*params.Nx+1 : l*params.Nx, 2) = (l-1)*params.Ly/h2out_nlines;
    end
  end


  
  if strcmp(flag, 'done')
    return
  end

  Nx = params.Nx;
  Ny = params.Ny;
  Nt = Nx.*Ny;

  tsteps = size(uu,2);
  disp(sprintf('t = %f, Nt = %d', tt(tsteps), tsteps));

  u = uu(:, tsteps);
  t = tt(:, tsteps);


 
  T  = reshape(u(0*Nt+1 : 1*Nt), Nx, Ny);
  ux = reshape(u(1*Nt+1 : 2*Nt), Nx, Ny);
  uy = reshape(u(2*Nt+1 : 3*Nt), Nx, Ny);
  ut = reshape(u(2*Nt+1 : 3*Nt), Nx, Ny);

  Tdx  = dx(T);
  Tdy  = dy(T);
  uxdx = dx(ux);
  uxdy = dy(ux);
  uydx = dx(uy);
  uydy = dy(uy);
  w = uxdy - uydx;
  w = w * 5;




  figure(1);

  plotsx = 3;
  plotsy = 2;

  f = 1;

  sum(sum(abs(T)))/size(T,1)/size(T,2)
  subplot(plotsy, plotsx, 1);
  image(100.*(T-params.TempOffset).*params.colormapOffset*f+params.colormapOffset); 
  axis square;
  title(sprintf('T  @  t = %f', t));
  if false
  hold on
  gridskip = 4;
  [x, y] = meshgrid(1:gridskip:params.Nx,1:gridskip:params.Ny);
  gridux = ux(1:gridskip:params.Nx, 1:gridskip:params.Ny);
  % prepare figures for plotting
  close all;

  % load color maps
  load('cm', 'mycmap');
  params.colormapOffset = 512;

  if (params.plotHydro || (params.plotMetric && params.metricOn))
    fig  = figure; 
    set(fig, 'Colormap', mycmap);
    set(fig, 'WindowStyle', 'docked');
  end
  refresh();
  pause(0.001);
  griduy = uy(1:gridskip:params.Nx, 1:gridskip:params.Ny);
  quiver(x, y, griduy, gridux);
  axis([1 params.Nx 1 params.Ny]);
  hold off
  end




  fv = 1;
  subplot(plotsy, plotsx, 2);
  image(ux*params.colormapOffset*fv +params.colormapOffset);
  axis square;
  title('ux');
  % if (VIDEO) & (frame_active)
  %   frame = getframe;
  %   writeVideo(vvx,frame);
  % end

  subplot(plotsy, plotsx, 3);
  image(uy*params.colormapOffset*fv +params.colormapOffset);
  axis square;
  title('uy');
  % if (VIDEO) & (frame_active)
  %   frame = getframe;
  %   writeVideo(vvy,frame);
  % end

  subplot(plotsy, plotsx, 4);
  %image(w*10*f*params.colormapOffset +params.colormapOffset);
  imagesc(w)
  axis square;
  title('w');
  % if (VIDEO) & (frame_active)
  %   frame = getframe;
  %   writeVideo(vvy,frame);
  % end

  maxw = max(max(abs(w)));
  w = w/maxw;
  imagesc(w);
  axis square;
  title('w auto');



  refresh();
end
